const util = require('../../../utils/util.js');
const api = require('../../../config/api.js');
const user = require('../../../utils/user.js');


const app = getApp()


// pages/ucenter/group/group.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone:''
  },

  getPhoneNumber(e) {
    let that=this
    console.log(e.detail.errMsg)
    console.log(e.detail.iv)
    console.log(e.detail.encryptedData)
    util.request(api.Phone, {
      encryptedData: e.detail.encryptedData,
      iv: e.detail.iv
    }, 'get', {
        'Content-Type': 'application/json',
        'X-Qxmall-Token': wx.getStorageSync('token')
      }).then(function (res) {
        console.log(res)
        wx.setStorageSync("phone", res.data.phone.phoneNumber)
        that.setData({
          phone:res.data.phone.phoneNumber
        })
      });

  },

  back_houtai: function (e) {
    if (app.globalData.hasLogin == true) {
      let that = this
      util.request(api.ReplenishUserInfo, {
        phone:that.data.phone,
        address: e.detail.value.address,
        birthday: e.detail.value.birthday,
        email: e.detail.value.email,
        idCard: e.detail.value.idCard,
        name: e.detail.value.name,
        namintroductione: e.detail.value.introduction
      }, 'post', {
          'Content-Type': 'application/json',
          'X-Qxmall-Token': wx.getStorageSync('token')
        }).then(function (res) {
         if(res.code==200){
           wx.navigateBack()
         }
        });
    }
  },

  begin(e) {
    if (this.data.checke == 1) {
      this.setData({
        checke: 0
      })
    } else {
      this.setData({
        checke: 1
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({

     phone:wx.getStorageSync("phone")
    })
     
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})